//
// Generated from archetype; please customize.
//

package com.blank.tile.ocmud

import java.net.ServerSocket
/**
 * Example Groovy class.
 */
class MUDServer
{
    def clientList = Vector()
    def clientThread = 
    {
        socket ->
        socket.withStreams
        {
            input, output ->
            def reader = input.newReader()
            while(true)
            {
                def buffer = reader.readLine()

                for(i in 0..<clientList.size())
                {
                    clientList.get(i).getOutputStream() << "echo: "  + buffer + "\n"
                }
            }
        }
    }
    
    def start() {
        def server = new ServerSocket(8131)
        
        while(true)
        {
            clientList.add(server.accept(clientThread))
        }
    }
}
